package com.itheima.homework01.listdemo03;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class ArrayDemo3 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("张三",23,"男"));
        list.add(new Student("李四",20,"男"));
        list.add(new Student("王五",25,"男"));
        int maxAge = list.get(0).getAge();
        int ageIndex = 0;
        for (int i = 1; i < list.size(); i++) {
            if (maxAge < list.get(i).getAge()) {
                maxAge = list.get(i).getAge();
            }
            ageIndex = i;
        }
        list.get(ageIndex).setName("小猪佩奇");
        list.forEach(student -> System.out.println(student));

    }
}
